<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        p {
            height: 50px;
            display: flex;
        }

        span {
            width: 50px;
            height: 50px;
            background-color: #ff0;
            text-align: center;
            line-height: 50px;
        }

        .disabled {
            background-color: #ddd;
        }
    </style>
</head>

<body>

    <p>
        <span class="reduce disabled">-</span>
        <input type="text" value="1">
        <span class="add">+</span>
    </p>

    <script>

        var oReduce = document.querySelector('.reduce');
        var oAdd = document.querySelector('.add');

        oAdd.onclick = function () {
            this.previousElementSibling.value++;
            if (this.previousElementSibling.previousElementSibling.classList.contains('disabled')) {
                this.previousElementSibling.previousElementSibling.classList.remove('disabled');
            }
        }


        oReduce.onclick = function () {
            // 首先判断能不能减
            if (this.classList.contains('disabled')) {
                return
            }
            this.nextElementSibling.value--;
            if (this.nextElementSibling.value == 1) {
                this.classList.add('disabled');
            }
        }

    </script>

</body>

</html>